/**
 * @author ChaP
 * @date 2019/05/21
 * @describe:
 */
package CodingTest.AC20190520;

import java.util.HashMap;

public class numberOfBoomerangs {
    public int numberOfBoomerangs(int[][] points){
        int len = points.length;
        int count = 0;
        int tempRes = 0;
        int result = 0;
        HashMap<Integer,Integer> dis = new HashMap<Integer,Integer>();
        for(int i =0;i<len;i++){
            for(int j =0;j<len;j++){
                int distance = (points[j][1] - points[i][1])*( points[j][1] - points[i][1])
                        +(points[j][0]-points[i][0])*(points[j][0]-points[i][0]);
                if(distance!=0){
                    if(dis.containsKey(distance)){
                        count = dis.get(distance);
                        dis.put(distance,count+1);
                        tempRes = tempRes + count;
                    }else{
                        dis.put(distance,1);
                    }
                }
            }
            result += tempRes*2;
            tempRes = 0;
            dis.clear();
        }
        return result;
    }


}
